package nfa;

import java.util.Set;

/**
 * @author haoly
 * @title NFADesign
 * @date 2025/4/16 15:07
 * @description NFADesign
 */
public class NFADesign<T> {
    private final T startState;

    private final Set<T> acceptStates;

    private NFARulebook<T> rulebook;

    public NFADesign(T startState, Set<T> acceptStates, NFARulebook<T> rulebook) {
        this.startState = startState;
        this.acceptStates = acceptStates;
        this.rulebook = rulebook;
    }



    public Boolean accepts(String s){
        NFA<T> nfa = toNFA();
        nfa.readString(s);
        return nfa.accepting();
    }

    public NFA<T> toNFA() {
        return new NFA<>(Set.of(this.startState), this.acceptStates, this.rulebook);
    }

    public NFA<T> toNFA(Set<T> currentStates) {
        return new NFA<>(currentStates, this.acceptStates, this.rulebook);
    }

    public T getStartState() {
        return startState;
    }

    public Set<T> getAcceptStates() {
        return acceptStates;
    }

    public NFARulebook<T> getRulebook() {
        return rulebook;
    }
}
